#ifndef XMMSCLIENTPP
#define XMMSCLIENTPP
#include <xmmsclient/xmmsclient++.h>
#include <xmmsclient/xmmsclient.h>
#endif
#ifndef BASICVIS_H
#define BASICVIS_H
#include "databackend.h"
#include <math.h>
#include <QWidget>
#include <QPixmap>
#include <QRectF>
#include <QTimer>
#include <QTimeLine>
#include <QPainter>
#include <QLinearGradient>
#include <QMouseEvent>
#include <QPainterPath>
#include <QtDebug>
#include <QStringList>
#include <QMenu>

#define WATERFALL_HEIGHT 40
#define VISWATCH 90
#define RADAR_RADIUS 80 //less than 128 please

enum VisType { SPEAKER, SPECTRUM, SCOPE, OZONE, WATERFALL, RADAR};
//QString names[]={"Speaker","Spectrum","Scope","Ozone","Waterfall","Radar"}
class Speaker;

class BasicVis:public QWidget {
Q_OBJECT
	private:
	VisType type;
	QStringList vis_names;
	DataBackend * conn;
	int numBars,fps,timerID;
	QLinearGradient * linearGrad;
	QImage fullSpeaker;
	QImage smallSpeaker;
	QMenu * menu;

	//XMMS2 Visualization data members
	int visSize;
	Xmms::VisualizationPtr fft_conn;	
	Xmms::VisualizationPtr pcm_conn;
	Xmms::VisualizationPtr peak_conn;	
	short data_buffer[1024];

	//For Speaker vis
	Speaker * t1;
	Speaker * t2;
	Speaker * t3;
	Speaker * t4;
	Speaker * sub;
	
	//For Ozone
	QPixmap screen_buf_3;
	void drawLightning(QColor clr, double freq, double x, double y, double dir, double pwr, double fullpwr);
	QPainter * oz_painter;

	//For Waterfall
	int num_colls;
	QPixmap screen_buf;

	//For radar
	int theta;
	bool fade;
	QPixmap screen_buf_2;
	QPixmap radar_screen;
	
	public:
	BasicVis(DataBackend * c,QWidget * parent = 0, Qt::WindowFlags f = 0);
	~BasicVis();
	void mousePressEvent(QMouseEvent * event);
	void paintEvent(QPaintEvent *);
	void resizeEvent(QResizeEvent *);
	void wheelEvent(QWheelEvent * event);
	void timerEvent(QTimerEvent *event);

	public slots:
	void setNumAndLen(int,int);
	void respondToConfigChange(QString,QVariant);
	void beginLoop();
	void changeVis(QAction*);
	void changeVis(int);
};

class Speaker:public QWidget {
Q_OBJECT
	private:
	DataBackend * conn;
	QPixmap fullSpeaker;
	QPixmap smallSpeaker;
	int frequency;
	int value,lastvalue,delta;
	bool draw; bool beat;

	public: 
	Speaker(DataBackend * c,int w, int h,int freq,int delta,QWidget * parent = 0, Qt::WindowFlags f = 0);
	void paintEvent(QPaintEvent *);
	void updateSpeaker(int newValue);
};



#endif
